import React from 'react';
import { ChildBenchMarkC, PrimaryC, FirstHeaderC, SecondHeaderC, DATA_ENTRY, AdvancedSearch, codeType } from '../../../comps';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';

class ChildBenchMarkDemo extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      init2: '801130.999',
      init3: undefined,
      init4: '002091.SZ',
    };

    setTimeout(() => {
      this.setState({
        init3: 'H11007.CSI',
      });
    }, 3000);
  }

  onClick2 = () => {
    this.state.BenchMarkC2.setSelect('H11007.CSI');
  };
  onClick3 = () => {
    this.state.BenchMarkC3.setSelect('H11007.CSI');
  };
  onClick4 = () => {
    this.state.BenchMarkC4.setSelect('60dd75675d737d14a156ef19');
  };

  render() {
    return (
      <div style={{ padding: '20px' }}>
        <FirstHeaderC title='基本用法' />
        <div style={{ width: '500px' }}>
          <SecondHeaderC title='无初始化值' />
          <ChildBenchMarkC rules={[{ required: true, message: `请输入` }]} form={this.props.form} dataIndex='bench1' onChange={(e) => console.log(e)} />
          <SecondHeaderC title='有初始化值-同步' />
          <ChildBenchMarkC
            form={this.props.form}
            dataIndex='bench2'
            initialValue={this.state.init2}
            onRef={(ref) => this.setState({ BenchMarkC2: ref })}
            onChange={(e) => console.log(e)}
          />
          <PrimaryC onClick={this.onClick2} title='修改' />
          <SecondHeaderC title='有初始化值-异步' />
          <ChildBenchMarkC
            form={this.props.form}
            dataIndex='bench3'
            initialValue={this.state.init3}
            onChange={(e) => console.log(e)}
            onRef={(ref) => this.setState({ BenchMarkC3: ref })}
          />
          <PrimaryC onClick={this.onClick3} title='修改' />
          <SecondHeaderC title='包含自定义子基准' />
          <ChildBenchMarkC
            form={this.props.form}
            dataIndex='bench4'
            includeBench={1}
            initialValue={this.state.init4}
            onChange={(e) => console.log(e)}
            onRef={(ref) => this.setState({ BenchMarkC4: ref })}
          />
          <PrimaryC onClick={this.onClick4} title='修改' />
          <SecondHeaderC title='设置校验规则' />
          <ChildBenchMarkC form={this.props.form} dataIndex='bench5' rules={[{ required: true, message: '请选择基准!' }]} onChange={(e) => console.log(e)} />
          <SecondHeaderC title='设置帮助信息' />
          <ChildBenchMarkC form={this.props.form} dataIndex='bench6' helper='lalal' onChange={(e) => console.log(e)} />
          <SecondHeaderC title='禁用' />
          <ChildBenchMarkC form={this.props.form} dataIndex='bench7' disabled={true} onChange={(e) => console.log(e)} />
        </div>
      </div>
    );
  }
}

export default Form.create()(ChildBenchMarkDemo);
